#ifndef HANDTRACKER_HPP
#define HANDTRACKER_HPP

#include "HandInterface.hpp"

class HandTracker : public AbstractHandTracker {
public:
	static AbstractHandTracker* init( bool	useHSV, float meanshiftWeightFactor, float processNoiseCovScalar, float measurementNoiseCovScalar,
									 float shortDistIgnoreThreshold, cv::Rect trackingRect, cv::Mat& initImage, cv::Ptr< GeometricGestureClassifier > gClassifier );

	cv::Rect track(cv::Mat& nextImage );
	void setForbiddenRect(cv::Rect& forbiddenRect);
	bool isHandActive();
	
protected:
	cv::Rect trackingRect;
	cv::Mat imgA;
	cv::Mat imgB;
	
	bool handActive;
	
private:
	
	HandTracker( bool useHSV, float meanshiftWeightFactor, float shortDistIgnoreThreshold, cv::Rect trackingRect, cv::Ptr< GeometricGestureClassifier > gClassifier, float measurementNoiseCovScalar );
	
	cv::Point2f initialLocationGuess( const cv::Mat& probImage );
	
	cv::Ptr< GeometricGestureClassifier > gClassifier;
	
	cv::Mat* imgPtr1;
	cv::Mat* imgPtr2;
	
	
	cv::KalmanFilter positionKF;
	
	float prevX;
	float prevY;	
	
	bool useHSV;
	
	vector<cv::Point2f> corners;
	vector<cv::Point2f> potentiallyReusedCorners;
	vector<cv::Point2f> reusedCorners;
	//FIX: when done with visualisation, update this to use swap of some sort? Could save some copying of data
	
	//FIX : Test these values //FULLTEST
	int maxCorners;
	int minCornersToTrack;
	double qualityLevel;
	double minDistance;
	
	float meanshiftWeightFactor;
	
	float cornerReuseErrorThreshold;
	
	float shortDistIgnoreThreshold; //FIXNOW should be scale dependent? -- needs FULL TESTING //FIXNOW //FULLTEST
	float accelerationIgnoreThreshold;
	
	vector<cv::Point2f> nextCorners;
	vector<uchar> cornersFound;
	vector<float> cornerErrors;
	
	
	float measurementNoiseCovScalar;
	
	
	cv::Rect forbiddenRect;
	

};

#endif
	
	
	